﻿#pragma once

#include "Common.hpp"
#include "Objective.hpp"
//#include "PageMap.h"
class PageCache
{
public:
	static PageCache* GetInstance()//初始化
	{
		return &_sInst;
	}

	//得到一个span
	span* NewSpan(const size_t& k);
	//找到对应的span
	span* MapObjectToSpan(void* start);

	void ReleaseSpanToPageCache(span* span);//合并大页
	std::mutex _pageMtx;
private:
	spanlist _spanLists[NPAGES];
	ObjectPool<span> _spanPool;
	PageCache()
	{}
	PageCache(const PageCache&) = delete;
	PageCache& operator=(const PageCache&) = delete;
	//记录页号所对应的span
	std::unordered_map<PAGE_ID, span*> _idspanMap;

	static PageCache _sInst;
};
